package com.wdress.base;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.apache.struts.action.DynaActionForm;
import org.hibernate.SQLQuery;
import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.hibernate.transform.Transformers;

import com.wdress.model.Wdress;
import com.wdress.util.HibernateUtil;

public class InitServlet extends javax.servlet.http.HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public InitServlet()  
    { 
        super(); 
    } 
    public void init() throws ServletException  {
    	ServletContext application=this.getServletContext();
		Session session = null;
		Transaction tx = null;
		try {
			session = HibernateUtil.getSessionFactory().openSession();
			tx = session.beginTransaction();
			application.setAttribute("dd", "dd") ;
		}catch(Exception e){
			e.printStackTrace();
		}
		finally {
			if(tx!=null){
				tx.commit();
			}
			if(session!=null ){
				session.close();
			}
		}
    }
}
